#include<iostream>
#include<algorithm>
using namespace std;
const int N = 1e5 + 10;
int arr[N];
int d[N];
int n;
int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> arr[i];
		d[i] = arr[i] - arr[i - 1];
	}
	int p = 0, q = 0;
	for (int i = 1; i <= n; i++) {
		if (d[i] >= 0)p += d[i];
		else q -= d[i];
	}
	cout << max(q, p) << endl;
	return 0;
}